1 module features.nuget; 2 public import feature; 3 import commons; 4 5 6 private Feature nuGetFeature; 7 8 /** 9 ```d 10 bool(ref Terminal t, ref RealTimeConsoleInput input, string command) 11 ``` 12 */ 13 Task!(callNuGetCommand) callNuGet; 14 15 /** 16 ```d 17 bool(ref Terminal t, ref RealTimeConsoleInput input, string reason, string packageName, string outputPath) 18 ``` 19 */ 20 Task!(installWithNuGetImpl) installWithNuGet; 21 22 private bool installWithNuGetImpl(Feature*[] dependencies, ref Terminal t, ref RealTimeConsoleInput input, string reason, string packageName, string outputPath) 23 { 24 t.writeln("Package '", packageName, "' will be downloaded for ", reason); 25 return t.wait(spawnShell(configs["nuGet"].str ~" install "~ packageName ~" -o "~ outputPath)) == 0; 26 } 27 28 private bool callNuGetCommand(Feature*[] dependencies, ref Terminal t, ref RealTimeConsoleInput input, string cmd) 29 { 30 return t.wait(spawnShell(configs["nuGet"].str ~" "~ cmd)) == 0; 31 } 32 33 void initialize() 34 { 35 static bool installNuGet( 36 ref Terminal t, 37 ref RealTimeConsoleInput input, 38 TargetVersion ver, 39 Download[] content 40 ) 41 { 42 configs["nuGet"] = buildNormalizedPath(content[0].getOutputPath); 43 updateConfigFile(); 44 return true; 45 } 46 47 import std.system; 48 nuGetFeature = Feature( 49 name: "NuGet CLI", 50 description: "A package manager for Visual Studio projects", 51 ExistenceChecker(["nuGet"]), 52 Installation([Download( 53 DownloadURL(windows: "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"), 54 "$CWD/buildtools/nuget".executableExtension 55 )], toDelegate(&installNuGet)), 56 startUsingFeature: null, 57 VersionRange(), 58 requiredOn: [OS.win32, OS.win64], 59 dependencies: null, 60 ); 61 } 62 63 void start() 64 { 65 callNuGet = Task!(callNuGetCommand)([&nuGetFeature]); 66 installWithNuGet = Task!(installWithNuGetImpl)([&nuGetFeature]); 67 }